package com.yxinsur.imc.common.validator;


import com.yxinsur.imc.common.constant.HttpStatus;
import com.yxinsur.imc.common.exception.BusinessException;
import com.yxinsur.imc.common.utils.StringUtils;

/**
 * @Title: Assert 
 * @Description: 断言
 * @version V1.0 
 */
public abstract class Assert {

    public static void isBlank(String str, String message) {
        if (StringUtils.isBlank(str)) {
            throw new BusinessException(message, HttpStatus.ERROR);
        }
    }

    public static void isTrue(boolean bool, String message) {
        if (bool) {
            throw new BusinessException(message,HttpStatus.ERROR);
        }
    }
    
    public static void isNull(Object object, String message) {
    	if (object == null) {
    		throw new BusinessException(message,HttpStatus.ERROR);
    	}
    }
    
    // 自定义code
    public static void isBlank(String str, String message, int code) {
        if (StringUtils.isBlank(str)) {
            throw new BusinessException(message,code);
        }
    }
    // 自定义code
    public static void isNull(Object object, String message, int code) {
        if (object == null) {
            throw new BusinessException(message,code);
        }
    }

}
